package com.shuqi.model.parse.parser;

import org.xml.sax.Attributes;

import com.shuqi.model.bean.GetUserOnlineInfo;
import com.shuqi.model.parse.HandlerBase;

public class GetUserInfoOnlineParser extends HandlerBase {
    private GetUserOnlineInfo info;

    public GetUserOnlineInfo getParsedData() {
        return info;
    }

    @Override
    public void startElement(String uri, String localName, String qName, Attributes atts) {
        if ("body".equals(localName)) {
            info = new GetUserOnlineInfo();
        } else if (localName.equals("serverinfo")) {
            info.setServerState(isNull(atts, "state"));
            info.setServerMessage(isNull(atts, "message"));
        } else if (localName.equals("UserInfo")) {
            info.setUserId(isNull(atts, "userId"));
            info.setNikeName(isNull(atts, "nickName"));
            info.setGender(isNull(atts, "gender"));
            info.setBanlance(isNull(atts, "balance"));
            info.setNewUser("1".equals(isNull(atts, "newUser")));
            info.setSession(isNull(atts, "session"));
        }
    }
}
